<template name="quarter">
  <div class="view">
    <h2 class="title">当季推荐</h2>
    <ul class="tabs">
      <li
        v-for="(item,i) in tabsList"
        :key="i"
        :class="{'is_this' : i+1 == month , 'afRight':true}"
        @mousemove="onTabs(i)"
      >{{item}}</li>
    </ul>
    <template v-for="item in quarterContent">
      <ul class="contentGroup" :key="item.id" v-if="month == item.month">
        <li
          class="quarterContent"
          v-for="(items,i) in item.contentList"
          :key="items.content_id"
          :style="{backgroundImage: 'url(' +items.img+ ')', width : i < 3 ? 323 + 'px' : 238 + 'px'}"
        >
          <span v-show="items.place !== ''" style="padding: 0 0 20px 20px;">{{items.place}}</span>
          <span class="name" v-show="items.place == ''">更多 <i class="el-icon-arrow-right"></i></span>
        </li>
      </ul>
    </template>
  </div>
</template>

<script>
import {mapState} from 'vuex'
export default {
  name: "quarter",
  data() {
    return {
      tabsList: [],
      month: null,
    };
  },
  computed:{
    ...mapState(['quarterContent'])
  },
  methods: {
    getData() {
      let tabs = [
        "1月",
        "2月",
        "3月",
        "4月",
        "5月",
        "6月",
        "7月",
        "8月",
        "9月",
        "10月",
        "11月",
        "12月"
      ];
      this.tabsList = tabs;
      this.$store.dispatch('reqQuarterContent')
    },
    getDateMonth() {
      let date = new Date();
      this.month = date.getMonth() + 1;
    },
    onTabs(i) {
      this.month = i + 1;
    }
  },
  mounted() {
    this.getData();
    this.getDateMonth();
  }
};
</script>

<style lang="stylus" scoped>
.view {
  width: 1000px;
  margin: auto;
  padding:40px 0;

  .title {
    text-align: center;
    font-weight: normal;
    margin: 25px;
  }

  .tabs {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    cursor: pointer;

    .is_this {
      color: orange;
      position: relative;

      &:before {
        content: '';
        width: 100%;
        height: 3px;
        background-color: orange;
        position: absolute;
        bottom: -12px;
      }
    }

    .afRight {
      position: relative;

      &:after {
        content: '';
        width: 1px;
        height: 16px;
        background-color: #eee;
        position: absolute;
        right: -27px;
        top: 3px;
      }

      &:last-child {
        &:after {
          content: '';
          width: 0;
          height: 0;
        }
      }
    }
  }

  .contentGroup {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    height: 480px;
  }

  .quarterContent {
    width: 323px;
    height: 220px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
    font-size: 20px;
    color: #ffffff;

    .name {
      display: flex;
      width: 100%;
      height: 100%;
      text-align: center;
      background-color: rgba(0, 0, 0, 0.5);
      justify-content: center;
      align-items: center;
    }
  }
}
</style>